﻿using HZY.Framework.DependencyInjection;
using SprayProcessSCADASystem.Common;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SprayProcessSCADASystem.Page
{
    public partial class PageSystemParamterSet : UIPage, ISingletonSelfDependency
    {
        public PageSystemParamterSet()
        {
            InitializeComponent();
            this.Load += PageSystemParamterSet_Load;
        }

        private void PageSystemParamterSet_Load(object? sender, EventArgs e)
        {
            txt_IpAddr.Text = Global.IpAddress;
            txt_PLCConnTimeOut.Text = Global.ConnectTimeOut.ToString();
            txt_Port.Text = Global.Port.ToString();
            txt_ReadTimeOut.Text = Global.ReadTimeInterval.ToString();
            txt_CPUType.Text = Global.CpuType.ToString();
            txt_ReConnTime.Text = Global.ReConnectTimeInterval.ToString();
            txt_SlotNum.Text = Global.Slot.ToString();
            txt_JiJiaNum.Text = Global.Rack.ToString();
            txt_PLCVarPath.Text = Global.PlcVarConfigPath.ToString();
        }

        private void uiTextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            if(Global.IniFile.Write("PLC参数", "变量表地址",txt_PLCVarPath.Text))
                Debug.WriteLine("变量表地址写入成功");
        }
    }
}
